/**
 * 已废弃
 */

import Queue from '../base/queue';

interface ItemQueueFunc {
    addItem(name: string, id: number, dis: string, num: number, val: number): void;
    delItem(): void;
    printAll(): void;
}

type ItemStruct = {
    itemName : string;
    itemID : number;
    itemDiscribtion : string;
    itemNum : number;
    itemValue : number;
}

export default class ItemQueue implements ItemQueueFunc{
    public item : ItemStruct;
    public items: Queue<ItemStruct>;
    
    private static instance : ItemQueue;

    constructor(capacity: number = 1000) {
        this.items = new Queue<ItemStruct>(capacity);
    }

    public static getInstance(capa: number = 1000) : ItemQueue{
        if(!this.instance) {
            this.instance = new ItemQueue(capa);
        }
        return ItemQueue.instance;
    }

    public addItem(itemName: string, itemID: number, itemDiscribtion: string = "这是一件商品", itemNum: number, itemValue: number): void {
        this.item = {
            itemName : itemName,
            itemID : itemID,
            itemDiscribtion : itemDiscribtion,
            itemNum : itemNum,
            itemValue : itemValue
        };
        this.items.enqueue(this.item);
    }

    public delItem() {
        this.items.dequeue();
    }

    public printAll() : string {
        return this.items.toString();
    }
}